#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QTimer>
#include "circle.h"
#include "pwm.h"
#include "gpio.h"
#include "goods.h"
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    QVector<QVector<int>> p;
    int direction_m;
    int direction_t;
    QSerialPort serial0;
    QSerialPort serial3;
    QSerialPort serial4;
    QSerialPort serial5;
    Pwm pwm_l,pwm_r;
    Gpio gpio_l_1,gpio_l_2,gpio_r_1,gpio_r_2;
    Circle c_00,c_01,c_02,c_10,c_11,c_12;
    Goods goods_1,goods_2,goods_3,goods_4;
    int run_flag;
    int navigation_flag;
    int yuju_0;
    int R_x;
    int R_y;
    int R1_x;
    int R1_y;
    int loc_aim_x,loc_aim_y;
    int loc_now_x,loc_now_y;
    int goods_num,goods_find_num;
    int Path_i;
    int goods_flag;
    int goods_show_flag;
    int tmp_data_flag;
    int getPoint0(Circle c1, Circle c2,Circle c3);
    int getPoint1(Circle c1, Circle c2,Circle c3);
    void goods_read(int goods_read_num);
    void goods_clear();
    void initSerialPort();//初始化串口函数
    void initTimer();
    void label_clear();


public slots:
        void handleTimeout();
        void motor_pwm();
        void serialRead5();
        void serialRead4();
        void serialRead0();
        void serialRead3();
private slots:
        void on_pushButton_goods_1_clicked();

        void on_pushButton_goods_2_clicked();

        void on_pushButton_goods_3_clicked();

        void on_pushButton_goods_4_clicked();



        void on_pushButton_deal_all_clicked();

        void on_pushButton_reduce_1_clicked();

        void on_pushButton_reduce_2_clicked();

        void on_pushButton_reduce_3_clicked();

        void on_pushButton_reduce_4_clicked();

        void on_pushButton_deal_1_clicked();

        void on_pushButton_deal_2_clicked();

        void on_pushButton_deal_3_clicked();

        void on_pushButton_deal_4_clicked();

        void on_pushButton_start_clicked();

        void on_pushButton_pay_clicked();

private:
    Ui::MainWindow *ui;
    QTimer *m_pTimer;
    QTimer *motor_pTimer;
};

#endif // MAINWINDOW_H
